__author__ = 'aesop'
#coding:utf-8
#用于处理微信网页授权发起的回调

import flask.request as request
import flask.abort as abort
import libs.weixinApi.get_openid_oauth2 as get_openid_oauth2


def wx_web_callback(app):
    @app.route("/wx-web-callback", methods=["GET", "POST"])
    def wx_callbck():
        code = request.args.get("code")
        state = request.args.get("state")

        openid_dic = get_openid_oauth2(code)
        if(openid_dic["err"] == "0"):
            openid = openid_dic["openid"]

        else:
            abort(500)


